//
//  UIButton+Extension.swift
//  EasyDana
//
//  Created by mac on 2024/10/12.
//

import UIKit

extension UIButton {
    @IBInspectable var useRighteousFont: Bool {
        set {
            if newValue {
                self.titleLabel?.font = UIFont(name: "Righteous-Regular", size: 20)
            }
        }
        get {
            return false
        }
    }
    
    static func swizzle() {
        let originalSelector = #selector(UIButton.init(coder:))
        let swizzledSelector = #selector(UIButton.my_init(coder:))
        let originalMethod = class_getInstanceMethod(UIButton.self, originalSelector)!
        let swizzledMethod = class_getInstanceMethod(UIButton.self, swizzledSelector)!
        method_exchangeImplementations(originalMethod, swizzledMethod)
    }
    
    @objc func my_init(coder: NSCoder) -> UIButton {
        let label = my_init(coder: coder)
        label.setTitle(label.title(for: .normal)?.locale, for: .normal)
        return label
    }
}
